package com.itheima.demo03;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class MainClass01 {
    public static void main(String[] args) {
        Collection<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        list.add("ccc");
        list.add("dddd");

        /*list.removeIf(
                (String s) -> {
                    return s.length() == 3;
                }
        );
        System.out.println(list);*/

        Iterator<String> it = list.iterator();
        while (it.hasNext()){
            String s = it.next();
            if ("bbb".equals(s)){
                it.remove();
            }
        }

        for (String s : list) {
            if ("bbb".equals(s)){
                s = "fff";
            }
            System.out.println(s);
        }
        System.out.println(list);
    }
}
